#!/usr/bin/env python3
"""
运行训练并显示进度
"""

import subprocess
import sys
import os

# 切换到正确的目录
os.chdir(r"D:\VSCodeProjects\UC_System\uc_model")

# 运行训练脚本
cmd = [sys.executable, "train_simple.py"]
process = subprocess.Popen(
    cmd,
    stdout=subprocess.PIPE,
    stderr=subprocess.STDOUT,
    universal_newlines=True,
    bufsize=1
)

print("训练开始...")
print("="*60)

# 实时输出
for line in process.stdout:
    print(line.rstrip())

# 等待完成
process.wait()
print("="*60)
print(f"训练结束，退出码: {process.returncode}")